#include "bsp.h"
#include "lpc_eeprom.h"

#define PAGE_OFFSET			0x10
#define PAGE_ADDR			  0x01
#define TEST_SIZE       0x40
uint8_t write_buffer[]="LPC1778 EEPROM FUNCTION TEST \r\n--- HELLO WORLD!!! ---\r\n";
uint8_t read_buffer[TEST_SIZE];
void hw_eeprom_test(void)
{
  int count;
  int i;
  
  count = sizeof(write_buffer);
  
  EEPROM_Init();
  printf("erase PAGES \r\n");
  for(i = 0x01; i < 5; i++){
    EEPROM_Erase(i);
  }  
  printf("write data \r\n");
  printf((char const*)write_buffer);
  EEPROM_Write(PAGE_OFFSET,PAGE_ADDR,(void*)write_buffer,MODE_8_BIT,count/1);
  printf("read data \r\n");
  EEPROM_Read(PAGE_OFFSET,PAGE_ADDR,(void*)read_buffer,MODE_16_BIT,TEST_SIZE/2);
  printf((char const*)read_buffer);
}